//
//  RBGoodsOrderApplyServicePopVC.m
//  zhongzhenglu
//
//  Created by XL on 2022/8/16.
//

#import "RBGoodsOrderApplyServicePopVC.h"
#import "RBDefine.h"
#import "UIView+RBAdd.h"
#import "UIScrollView+RBAdd.h"
#import <Masonry.h>
#import "RBThemeConfig.h"
#import <UIColor+YYAdd.h>
#import <UIView+YYAdd.h>
#import "RanTool.h"

@interface RBGoodsOrderApplyServicePopVC ()


@end

@implementation RBGoodsOrderApplyServicePopVC

#pragma mark - Lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self setup];
}

#pragma mark - Private

- (void)setup
{
    self.view.backgroundColor = UIColor.clearColor;
    
    self.contentView = UIView.new;
    self.contentView.backgroundColor = UIColor.whiteColor;
    [self.view addSubview:self.contentView];
    self.contentView.frame = CGRectMake(0, kRBMainScreenHeight, kRBMainScreenWidth, Zoom(128) + kRBSafeBottomHeight);
    
    NSArray *titles = @[@"申请退款", @"申请售后"];
    for (NSInteger i = 0; i < titles.count; i++)
    {
        CGFloat itemH = Zoom(64);
        UIView *view = UIView.new;
        view.tag = i;
        [view rbAddTapGesWithTarget:self action:@selector(cellTapped:)];
        [self.contentView view_addView:view withHeight:itemH width:kRBMainScreenWidth top:0 bottom:CGFLOAT_MIN left:0 right:0 centerX:0];
        UILabel *titleL = [RanTool labelWithFontSize:Zoom(14) weight:1 color:[RBThemeConfig textBlackColor] align:0 text:titles[i]];
        [view addSubview:titleL];
        [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(Zoom(18));
            make.centerY.mas_equalTo(0);
        }];
        UIImageView *imgView = [RanTool imgViewWithMode:1 radius:0 imgName:@"mine_arrow_right"];
        [view addSubview:imgView];
        [imgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-Zoom(12));
            make.width.mas_equalTo(Zoom(7));
            make.height.mas_equalTo(Zoom(13));
            make.centerY.mas_equalTo(0);
        }];
    }
}

- (void)show
{
    __weak typeof(self) weakSelf = self;
    [UIView animateWithDuration:0.15 animations:^{
        weakSelf.view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
        weakSelf.contentView.bottom = kRBMainScreenHeight;
    }];
}

- (void)dismiss
{
    __weak typeof(self) weakSelf = self;
    [UIView animateWithDuration:0.15 animations:^{
        weakSelf.view.backgroundColor = [UIColor colorWithWhite:0 alpha:0];
        weakSelf.contentView.top = kRBMainScreenHeight;
    } completion:^(BOOL finished) {
        [weakSelf dismissViewControllerAnimated:NO completion:nil];
    }];
}

#pragma mark - Network

#pragma mark - Event

- (void)cellTapped: (UITapGestureRecognizer *)ges
{
    if (self.block)
    {
        self.block(ges.view.tag);
    }
    [self dismissViewControllerAnimated:NO completion:nil];
}

#pragma mark - Setter

#pragma mark - Getter

@end
